package cn.iocoder.yudao.module.member.framework;

import cn.iocoder.yudao.framework.datapermission.v1.UniDataPermissionRuleCustomizer;
import cn.iocoder.yudao.module.member.vip.dal.dataobject.VipOrderDO;
import cn.iocoder.yudao.module.member.vip.dal.dataobject.VipUserDO;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * permission 组件的配置类
 */
@Configuration(proxyBeanMethods = false, value = "memberPermissionConfiguration")
public class DataPermissionConfiguration {

    @Bean
    public UniDataPermissionRuleCustomizer memberDataPermissionRuleCustomizer() {
        return rule -> {
            // shop 基于店铺的数据权限
            rule.addDataColumn(VipOrderDO.class, "from_shop_id", "shop_id"); // WHERE from_shop_id = ?
            rule.addDataColumn(VipUserDO.class, "bind_shop_id", "shop_id"); // WHERE bind_shop_id = ?
        };
    }

}
